package com.tinysand.advert.support;

import com.tinysand.advert.constant.CommonStatus;
import com.tinysand.advert.entity.Advertisement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 广告操作请求对象
 *
 * Created By TINY
 * Create Time 2020/2/21
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AdvertRequest {

    /* 广告名称 */
    private String name;

    /* 广告类型 */
    private Integer type;

    /* 广告物料类型 */
    private Integer materialType;

    /* 广告高度 */
    private Integer height;

    /* 广告宽度 */
    private Integer width;

    /* 广告大小 */
    private Long size;

    /* 广告持续时间 */
    private Integer duration;

    /* 创建广告的用户id */
    private Long userId;

    /* 广告对应url */
    private String url;

    /* 将请求中的参数值设置到对应的广告实体类中 */
    public Advertisement convertToEntity() {
        Advertisement advertisement = new Advertisement();
        advertisement.setName(name);
        advertisement.setType(type);
        advertisement.setMaterialType(materialType);
        advertisement.setHeight(height);
        advertisement.setWidth(width);
        advertisement.setSize(size);
        advertisement.setDuration(duration);
        advertisement.setAuditStatus(CommonStatus.VALID.getStatus());
        advertisement.setUserId(userId);
        advertisement.setUrl(url);
        advertisement.setCreateTime(new Date());
        advertisement.setUpdateTime(advertisement.getCreateTime());

        return advertisement;
    }
}
